package com.digitalchina.lxnsy.activity.old;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bigkoo.pickerview.OptionsPickerView;
import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.api.BusinessAccount;
import com.digitalchina.lxnsy.api.BusinessExpert;
import com.digitalchina.lxnsy.api.BusinessFile;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.constant.MSG;
import com.digitalchina.lxnsy.entity.ExpertClassificationVO;
import com.digitalchina.lxnsy.entity.ExpertTitleVO;
import com.digitalchina.lxnsy.entity.FileVO;
import com.digitalchina.lxnsy.entity.OrganizationVO;
import com.digitalchina.lxnsy.loader.GlideImageLoader;
import com.digitalchina.lxnsy.toolkit.ActivityTaskManager;
import com.digitalchina.lxnsy.toolkit.DateStyle;
import com.digitalchina.lxnsy.toolkit.DateUtil;
import com.digitalchina.lxnsy.toolkit.FastJsonUtil;
import com.digitalchina.lxnsy.toolkit.FrescoUtil;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.toolkit.StringUtil;
import com.digitalchina.lxnsy.xml.ExpertInfoXML;
import com.digitalchina.lxnsy.xml.UserXML;
import com.facebook.drawee.view.SimpleDraweeView;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.lzy.imagepicker.view.CropImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import chihane.jdaddressselector.BottomDialog;
import chihane.jdaddressselector.OnAddressSelectedListener;
import chihane.jdaddressselector.model.City;
import chihane.jdaddressselector.model.County;
import chihane.jdaddressselector.model.Province;
import chihane.jdaddressselector.model.Street;

import static com.digitalchina.lxnsy.activity.old.AccountPersonManagementActivity.REQUEST_CODE_EDIT;


/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.activity
 * 创建人：郑皓
 * 创建时间：2017/7/18 19:59
 * 修改备注：
 * ================================================
 */
public class SaveExpertInfoActivity extends BaseActivity {
    @Bind(R.id.iv_expert_avatar)
    SimpleDraweeView ivExpertAvatar;
    @Bind(R.id.tv_expert_true_name)
    TextView tvExpertTrueName;
    @Bind(R.id.tv_expert_sex)
    TextView tvExpertSex;
    @Bind(R.id.tv_expert_title)
    TextView tvExpertTitle;
    @Bind(R.id.tv_expert_company)
    TextView tvExpertCompany;
    @Bind(R.id.tv_expert_address)
    TextView tvExpertAddress;
    @Bind(R.id.tv_expert_address_detail)
    TextView tvExpertAddressDetail;
    @Bind(R.id.tv_expert_title_number)
    TextView tvExpertTitleNumber;
    @Bind(R.id.iv_expert_title_photo)
    SimpleDraweeView ivExpertTitlePhoto;
    @Bind(R.id.tv_expert_id_number)
    TextView tvExpertIdNumber;
    @Bind(R.id.iv_expert_id_photo)
    SimpleDraweeView ivExpertIdPhoto;
    @Bind(R.id.tv_expert_achievement)
    TextView tvExpertAchievement;
    @Bind(R.id.tv_expert_intro)
    TextView tvExpertIntro;
    @Bind(R.id.tv_expert_area)
    TextView tvExpertArea;
    @Bind(R.id.tv_expert_company_other)
    TextView tvExpertCompanyOther;
    @Bind(R.id.rl_expert_company_other)
    RelativeLayout rlExpertCompanyOther;

    private int msgWhat;
    // 图片
    public static final int REQUEST_CODE_SELECT = 100;
    private ArrayList<ImageItem> selectedImageList = new ArrayList<>(); //当前选择的所有图片
    private String filePath = ""; // 图片地址
    private int fileType = -1;  // 0-头像 1-职称照片 2-身份证照片
    // 性别选择器
    private OptionsPickerView pvSex;
    private List<String> sexVOList = new ArrayList<>();
    // 专家职称List
    private List<ExpertTitleVO> expertTitleVOList = new ArrayList<>();
    // 专家职称选择器
    private OptionsPickerView pvExpertTitle;
    // 专家分类List
    private List<ExpertClassificationVO> expertClassificationVOList = new ArrayList<>();

    // 提交数据array
    private String[] value = new String[20];
    private String photo = "";
    private String trueName = "";
    private String sex = "";
    private String expertTitleId = "";
    //    private String company = "";
    private String addressDetail = "";
    private String titleNumber = "";
    private String expertTitleImage = "";
    private String idCardNo = "";
    private String idCardImage = "";
    private String achievement = "";
    private String intro = "";
    // 地址code
    private String provinceCode = "";
    private String cityCode = "";
    private String countyCode = "";
    // 领域
    private String expertAreaTypeCode = "";
    private String expertAreaDirectionCode = "";
    private OptionsPickerView pvOrganization;

    // 工作单位id
    private String organizationId = "";
    private String otherAddress = "";

    @Override
    public void setLayout() {
        setContentLayout(R.layout.activity_save_expert_info);
        setTitle("专家信息");
    }

    @Override
    public void initMember() {

        // 获取工作单位
        BusinessAccount.organizationList(this, mHandler);

        if (getIntent().hasExtra("AuditStateActivity"))
            setValueXML();
        initValue();
        initSexData();
    }

    private void setValueXML() {

        // 赋值
        photo = ExpertInfoXML.getPhoto(this);
        trueName = ExpertInfoXML.getExpertName(this);
        sex = ExpertInfoXML.getExpertSex(this);
        expertTitleId = ExpertInfoXML.getExpertTitleCode(this);
//        company = ExpertInfoXML.getWorkUnit(this);
        provinceCode = ExpertInfoXML.getProvinceCode(this);
        cityCode = ExpertInfoXML.getCityCode(this);
        countyCode = ExpertInfoXML.getCountyCode(this);
        addressDetail = ExpertInfoXML.getAddressDetail(this);
        titleNumber = ExpertInfoXML.getExpertTitleNum(this);
        expertTitleImage = ExpertInfoXML.getExpertTitleImage(this);
        idCardNo = ExpertInfoXML.getIdCardNum(this);
        idCardImage = ExpertInfoXML.getIdCardImage(this);
        achievement = ExpertInfoXML.getAchievement(this);
        intro = ExpertInfoXML.getExpertIntroduce(this);
        expertAreaTypeCode = ExpertInfoXML.getExpertAreaType(this);
        expertAreaDirectionCode = ExpertInfoXML.getExpertAreaDirection(this);
        organizationId = ExpertInfoXML.getOrganizationID(this);
        otherAddress = ExpertInfoXML.getOtherAddress(this);

        // 设置UI
        FrescoUtil.showImageSmall(photo, ivExpertAvatar);
        tvExpertTrueName.setText(trueName);
        tvExpertSex.setText(sex);
        tvExpertTitle.setText(ExpertInfoXML.getExpertTitleName(this));
//        tvExpertCompany.setText(company);
        tvExpertAddress.setText(ExpertInfoXML.getAddress(this));
        tvExpertAddressDetail.setText(addressDetail);
        tvExpertIdNumber.setText(ExpertInfoXML.getIdCardNum(this));
        tvExpertTitleNumber.setText(titleNumber);
        FrescoUtil.showImageSmall(expertTitleImage, ivExpertTitlePhoto);
        FrescoUtil.showImageSmall(idCardImage, ivExpertIdPhoto);
        tvExpertAchievement.setText(achievement);
        tvExpertIntro.setText(intro);
        tvExpertArea.setText(ExpertInfoXML.getExpertClassification(this));

        // 工作单位
        tvExpertCompany.setText(ExpertInfoXML.getOrganizationName(this));
        if (ExpertInfoXML.getOrganizationName(this).equals("其他")) {
            rlExpertCompanyOther.setVisibility(View.VISIBLE);
            tvExpertCompanyOther.setText(otherAddress);
        }
    }

    /**
     * 工作单位选择器
     *
     * @param list
     */
    private void initOrganization(final List<OrganizationVO> list) {


        pvOrganization = new OptionsPickerView.Builder(SaveExpertInfoActivity.this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                String select = list.get(options1).getPickerViewText();
                tvExpertCompany.setText(select);
                organizationId = list.get(options1).getId();
                otherAddress = "";
                tvExpertCompanyOther.setText(otherAddress);
                ExpertInfoXML.setOtherAddress(SaveExpertInfoActivity.this, otherAddress);
                if (select.equals("其他")) {
                    rlExpertCompanyOther.setVisibility(View.VISIBLE);
                } else
                    rlExpertCompanyOther.setVisibility(View.GONE);

            }
        })
                .setSubCalSize(16)//确定取消按钮大小
                .setLineSpacingMultiplier(1.5f) //设置两横线之间的间隔倍数（范围：1.2 - 2.0倍 文字高度）
                .setDividerColor(getResources().getColor(R.color.colorFontLightGrayB))//设置分割线的颜色
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(18)//设置滚轮文字大小
                .setSelectOptions(0)  //设置默认选中项
                .build();

        pvOrganization.setPicker(list);
    }

    /**
     * 初始化数组
     */
    private void initValue() {
        for (int i = 0; i < value.length; i++) {
            value[i] = "";
        }
    }

    @Override
    public void addListener() {

    }

    @Override
    public void setHandler() {
        mHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                super.handleMessage(msg);
                dismissDialog();
                msgWhat = msg.what;
                switch (msgWhat) {
                    case MSG.MSG_FILE_UPLOAD_SUCCESS:  // 上传图片
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_FILE_UPLOAD_FIELD:
                        showToast(msg.obj.toString());
                        break;
                    case MSG.MSG_SAVE_EXPERT_INFO_SUCCESS: // 提交成功
                        showToast("提交成功");
                        UserXML.setTodayLogin(SaveExpertInfoActivity.this, DateUtil.getCurrentDate(DateStyle.YYYY_MM_DD));
                        UserXML.setLoginStatus(SaveExpertInfoActivity.this, UserXML.USER_IS_LOGIN_VALUE);
                        ActivityTaskManager.getInstance().closeActivity(RegisterActivity.class);
                        ActivityTaskManager.getInstance().closeActivity(LoginActivity.class);
                        if (!ActivityTaskManager.getInstance().hasActivity(MainActivity.class)) {
                            GotoUtil.gotoActivity(SaveExpertInfoActivity.this, MainActivity.class);
                        }
                        finish();
                        break;
                    case MSG.MSG_SAVE_EXPERT_INFO_FIELD:
                        showToast(msg.obj.toString());
                        break;
                    case MSG.MSG_EXPERT_TITLE_LIST_SUCCESS: // 获取专家职称接口
                        callBack(msg.obj);
                        break;
                    case MSG.MSG_EXPERT_TITLE_LIST_FIELD:
                        showToast(msg.obj.toString());
                        break;
                    case MSG.MSG_ORGANIZATION_LIST_SUCCESS: // 工作地址
                        List<OrganizationVO> organizationVOList = FastJsonUtil.getListBean(msg.obj.toString(), "list", OrganizationVO.class);
                        if (organizationVOList != null)
                            initOrganization(organizationVOList);
                        break;
                }
            }
        };
    }

    @Override
    public void callBack(Object object) {
        switch (msgWhat) {
            case MSG.MSG_FILE_UPLOAD_SUCCESS:  // 上传图片成功后 返回FileName
                FileVO fileVO = FastJsonUtil.getBean(object.toString(), "body", "fileStorage", FileVO.class);
                if (fileVO == null)
                    return;
                switch (fileType) {
                    case 0:
                        photo = fileVO.getName();
                        FrescoUtil.showImageSmall(photo, ivExpertAvatar);
                        break;
                    case 1:
                        expertTitleImage = fileVO.getName();
                        FrescoUtil.showImageSmall(expertTitleImage, ivExpertTitlePhoto);
                        break;
                    case 2:
                        idCardImage = fileVO.getName();
                        FrescoUtil.showImageSmall(idCardImage, ivExpertIdPhoto);
                        break;
                }
                break;
            case MSG.MSG_EXPERT_TITLE_LIST_SUCCESS: // 获取专家职称接口
                expertTitleVOList = FastJsonUtil.getListBean(object.toString(), "titleList", ExpertTitleVO.class);
                if (expertTitleVOList != null && expertTitleVOList.size() > 0) {
                    initExpertTitleData();
                    pvExpertTitle.show();
                } else
                    showToast("获取专家职称失败");
                break;
        }
    }

    @Override
    public void rightOnClick() {

    }


    /**
     * 专家职称选择器
     */
    private void initExpertTitleData() {


        pvExpertTitle = new OptionsPickerView.Builder(SaveExpertInfoActivity.this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                String select = expertTitleVOList.get(options1).getPickerViewText();
                tvExpertTitle.setText(select);
                expertTitleId = expertTitleVOList.get(options1).getId();
            }
        })
                .setSubCalSize(16)//确定取消按钮大小
                .setLineSpacingMultiplier(1.5f) //设置两横线之间的间隔倍数（范围：1.2 - 2.0倍 文字高度）
                .setDividerColor(getResources().getColor(R.color.colorFontLightGrayB))//设置分割线的颜色
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(18)//设置滚轮文字大小
                .setSelectOptions(0)  //设置默认选中项
                .build();

        pvExpertTitle.setPicker(expertTitleVOList);
    }

    /**
     * 性别选择器
     */
    private void initSexData() {

        sexVOList.add("男");
        sexVOList.add("女");

        pvSex = new OptionsPickerView.Builder(SaveExpertInfoActivity.this, new OptionsPickerView.OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                String select = sexVOList.get(options1);
                tvExpertSex.setText(select);
                sex = select;
            }
        })
                .setSubCalSize(16)//确定取消按钮大小
                .setLineSpacingMultiplier(1.5f) //设置两横线之间的间隔倍数（范围：1.2 - 2.0倍 文字高度）
                .setDividerColor(getResources().getColor(R.color.colorFontLightGrayB))//设置分割线的颜色
                .setTextColorCenter(Color.BLACK) //设置选中项文字颜色
                .setContentTextSize(18)//设置滚轮文字大小
                .setSelectOptions(0)  //设置默认选中项
                .build();

        pvSex.setPicker(sexVOList);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }


    /**
     * 修改头像跳转至自定义相册
     */
    private void selectImage(int fileType) {
        this.fileType = fileType;
        ImagePicker imagePicker = ImagePicker.getInstance();
        imagePicker.setImageLoader(new GlideImageLoader());   //设置图片加载器
        imagePicker.setShowCamera(true);  //显示拍照按钮
        imagePicker.setSelectLimit(1);    //选中数量限制
        imagePicker.setMultiMode(false);    //是否多选模式
        if (fileType == 0) {
            imagePicker.setCrop(true);        //允许裁剪（单选才有效）
            imagePicker.setSaveRectangle(true); //是否按矩形区域保存
            imagePicker.setStyle(CropImageView.Style.RECTANGLE);  //裁剪框的形状
            imagePicker.setFocusWidth(380);   //裁剪框的宽度。单位像素（圆形自动取宽高最小值）
            imagePicker.setFocusHeight(380);  //裁剪框的高度。单位像素（圆形自动取宽高最小值）
            imagePicker.setOutPutX(400);//保存文件的宽度。单位像素
            imagePicker.setOutPutY(400);//保存文件的高度。单位像素
        } else
            imagePicker.setCrop(false);
        Intent intent = new Intent(SaveExpertInfoActivity.this, ImageGridActivity.class);
        startActivityForResult(intent, REQUEST_CODE_SELECT);
    }

    /**
     * 跳转回调
     *
     * @param requestCode
     * @param resultCode
     * @param data
     */
    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK && data != null && requestCode == REQUEST_CODE_EDIT) {

            switch (data.getStringExtra("type")) {
                case "trueName": // 真实姓名
                    trueName = data.getStringExtra("edit");
                    tvExpertTrueName.setText(trueName);
                    break;
                case "company": // 工作单位
                    otherAddress = data.getStringExtra("edit");
                    tvExpertCompanyOther.setText(otherAddress);
                    break;
                case "addressDetail": // 详细地址
                    addressDetail = data.getStringExtra("edit");
                    tvExpertAddressDetail.setText(addressDetail);
                    break;
                case "titleNumber": // 专家职称号
                    titleNumber = data.getStringExtra("edit");
                    tvExpertTitleNumber.setText(titleNumber);
                    break;
                case "idCardNo": // 身份证号
                    idCardNo = data.getStringExtra("edit");
                    tvExpertIdNumber.setText(idCardNo);
                    break;
                case "achievement": // 个人成就
                    achievement = data.getStringExtra("edit");
                    tvExpertAchievement.setText(achievement);
                    break;
                case "intro": // 个人简介
                    intro = data.getStringExtra("edit");
                    tvExpertIntro.setText(intro);
                    break;
                case "area": // 领域说明
                    expertAreaTypeCode = data.getStringExtra("expertAreaTypeCode");
                    expertAreaDirectionCode = data.getStringExtra("expertAreaDirectionCode");
                    tvExpertArea.setText(data.getStringExtra("tvExpertArea"));
                    break;
            }

        } else if (resultCode == ImagePicker.RESULT_CODE_ITEMS) {
            //添加图片返回
            if (data != null && requestCode == REQUEST_CODE_SELECT) {
                showDialog("上传中,请稍候!");
                ArrayList<ImageItem> images = (ArrayList<ImageItem>) data.getSerializableExtra(ImagePicker.EXTRA_RESULT_ITEMS);
                filePath = images.get(0).path;
                selectedImageList.addAll(images);
                BusinessFile.imageCompressAndUpload(SaveExpertInfoActivity.this, filePath, mHandler);
            }
        }
    }


    /**
     * 跳转到编辑页面
     *
     * @param type 标记修改的类型
     */
    private void gotoEditActivity(String type, String content) {
        Intent intent = new Intent(SaveExpertInfoActivity.this, EditExpertInfoActivity.class);
        intent.putExtra("type", type);
        intent.putExtra("content", content);
        startActivityForResult(intent, REQUEST_CODE_EDIT);
    }

    @OnClick({R.id.rl_expert_avatar, R.id.rl_expert_true_name, R.id.rl_expert_sex, R.id.rl_expert_title, R.id.rl_expert_company, R.id.rl_expert_address, R.id.rl_expert_address_detail,
            R.id.rl_expert_title_number, R.id.rl_expert_title_photo, R.id.rl_expert_id_number, R.id.rl_expert_id_photo, R.id.rl_expert_achievement, R.id.rl_expert_intro,
            R.id.rl_expert_area, R.id.btn_expert_submit, R.id.rl_expert_company_other})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.rl_expert_avatar: // 头像
                selectImage(0);
                break;
            case R.id.rl_expert_true_name: // 真实姓名
                gotoEditActivity("trueName", trueName);
                break;
            case R.id.rl_expert_sex: // 性别
                pvSex.show();
                break;
            case R.id.rl_expert_title: // 专家职称
                getExpertTitle();
                break;
            case R.id.rl_expert_company: // 工作单位
                if (pvOrganization != null)
                    pvOrganization.show();
                break;
            case R.id.rl_expert_company_other: // 工作单位other
                gotoEditActivity("company", otherAddress);
                break;
            case R.id.rl_expert_address: // 所在区域
                showAddressPicker();
                break;
            case R.id.rl_expert_address_detail: // 详细地址
                gotoEditActivity("addressDetail", addressDetail);
                break;
            case R.id.rl_expert_title_number: // 专家职称号
                gotoEditActivity("titleNumber", titleNumber);
                break;
            case R.id.rl_expert_title_photo: // 专家职称照片
                selectImage(1);
                break;
            case R.id.rl_expert_id_number: // 身份证号
                gotoEditActivity("idCardNo", idCardNo);
                break;
            case R.id.rl_expert_id_photo: // 身份证照片
                selectImage(2);
                break;
            case R.id.rl_expert_achievement: // 个人成就
                gotoEditActivity("achievement", achievement);
                break;
            case R.id.rl_expert_intro: // 个人简介
                gotoEditActivity("intro", intro);
                break;
            case R.id.rl_expert_area: // 专业领域
                Intent intent = new Intent(SaveExpertInfoActivity.this, ExpertInfoAreaActivity.class);
                startActivityForResult(intent, REQUEST_CODE_EDIT);
                break;
            case R.id.btn_expert_submit: // 提交
                submitValue();
                break;
        }
    }


    /**
     * 所在区域选择
     */
    private void showAddressPicker() {
        final BottomDialog bottomDialog = new BottomDialog(SaveExpertInfoActivity.this);
        bottomDialog.setOnAddressSelectedListener(new OnAddressSelectedListener() {
            @Override
            public void onAddressSelected(Province province, City city, County county, Street street) {
                provinceCode = province.province_code;
                cityCode = city != null ? city.city_code : "";
                countyCode = county != null ? county.county_code : "";
                tvExpertAddress.setText(String.format("%s %s %s", province.province_name,
                        city != null ? city.city_name : "", county != null ? county.county_name : ""));
                bottomDialog.dismiss();
            }
        });
        bottomDialog.show();
    }

    /**
     * 获取专家职称
     */
    private void getExpertTitle() {
        if (expertTitleVOList.size() <= 0) {
            BusinessExpert.expertTitleList(this, mHandler);
        } else
            pvExpertTitle.show();
    }

    /**
     * 提交数据
     * params.put("photo", value[0]);      // 头像
     * params.put("expertId", value[1]);   // 专家useraccid
     * params.put("expertName", value[2]); // 真实姓名
     * params.put("expertSex", value[3]);      // 专家性别
     * params.put("expertTitleId", value[4]);      // 专家职称id
     * params.put("workUnit", value[5]);      // 工作单位
     * params.put("provinceCode", value[6]);      // 省份code
     * params.put("cityCode", value[7]);      // 市 code
     * params.put("countyCode", value[8]);      // 区县 code
     * params.put("addressDetail", value[9]);      // 详细地址
     * params.put("expertTitleNum", value[10]);      // 专家职称号
     * params.put("expertTitleImage", value[11]);      // 专家职称照片
     * params.put("idCardNum", value[12]);      // 身份证号
     * params.put("idCardImage", value[13]);      // 身份证照片
     * params.put("expertIntroduce", value[14]);      // 个人简介
     * params.put("achievement", value[15]);      // 个人成就
     * params.put("expertAreaTypeCode", value[16]);      // 专家领域（三类）
     * params.put("expertAreaDirectionCode", value[17]);      // 专家领域（方向）
     * params.put("expertAreaDirectionCode", value[18]);      // 工作单位
     * params.put("expertAreaDirectionCode", value[19]);      // 其他工作单位
     * 个人成就、工作单位、头像、性别四个字段为非必填项
     */
    private void submitValue() {
        value[0] = photo;
        value[1] = UserXML.getUserId(this);
        value[2] = trueName;
        value[3] = sex;
        value[4] = expertTitleId;
        value[5] = "";
        value[6] = provinceCode;
        value[7] = cityCode;
        value[8] = countyCode;
        value[9] = addressDetail;
        value[10] = titleNumber;
        value[11] = expertTitleImage;
        value[12] = idCardNo;
        value[13] = idCardImage;
        value[14] = achievement;
        value[15] = intro;
        value[16] = expertAreaTypeCode;
        value[17] = expertAreaDirectionCode;
        value[18] = organizationId;
        value[19] = tvExpertCompanyOther.getText().toString();

        if (StringUtil.isStrEmpty(value[2])) {
            showToast("请填写真实姓名");
            return;
        }
        if (StringUtil.isStrEmpty(value[3])) {
            showToast("请选择性别");
            return;
        }
        if (StringUtil.isStrEmpty(value[4])) {
            showToast("请选择专家职称");
            return;
        }
        if (StringUtil.isStrEmpty(value[6])) {
            showToast("请填写工作区域");
            return;
        }

//        if (StringUtil.isStrEmpty(value[10]) || StringUtil.isStrEmpty(value[11])) {
//            if (StringUtil.isStrEmpty(value[13]) || StringUtil.isStrEmpty(value[12])) {
//                showToast("专家职称信息与身份信息两组至少填写一组");
//                return;
//            }
//        }

//        if (StringUtil.isStrEmpty(value[15])) {
//            showToast("请填写个人简介");
//            return;
//        }
        if (StringUtil.isStrEmpty(value[16])) {
            showToast("请选择专家领域");
            return;
        }
        if (StringUtil.isStrEmpty(value[18])) {
            showToast("请选择工作单位");
            return;
        }
        if (tvExpertCompany.getText().toString().equals("其他") && StringUtil.isStrEmpty(value[19])) {
            showToast("请填写工作单位");
            return;
        }

        BusinessExpert.saveExpertInfo(this, value, mHandler);
    }
}
